package utils;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class OrcUtils {
    public static List<String> readList(String file) {
        File imageFile = new File(file);
        ITesseract instance = new Tesseract();  // JNA Interface Mapping
        instance.setDatapath("D:\\AutoScreenCapture");
//         ITesseract instance = new Tesseract1(); // JNA Direct Mapping
        instance.setLanguage("chi_sim");//添加中文字库
        try {
            String result = instance.doOCR(imageFile);
            String[] arr = result.split("\n");
            return Arrays.asList(arr);
        } catch (TesseractException e) {
            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    public static void main(String[] args) {
        OrcUtils.readList("D:\\AutoScreenCapture\\20201219_142620.png");
    }
}

